import { apiGet, apiPost } from '../func/fetch'
import type { routerInterface, userInfoInterface } from './type'
import { ContentType } from '@/api/global.ts'

const API = {
  userInfo: '/base-user-permission/user/detail/token',
  routerTree: '/base-user-permission/menu/routers?platformCode=face-ID',
  getLang: '/base-user-permission/user/language/get',
  setLang: '/base-user-permission/user/language/set',
  logOut: '/base-user-permission/sso/logout',
  platformList: '/base-user-permission/platform/list',
  permissions: '/base-user-permission/menu/permissions',
}
export const getUserInfo = (): Promise<userInfoInterface> => {
  return apiGet(API.userInfo)
}
export const getRouterTree = (): Promise<any[]> => {
  return apiGet(API.routerTree)
}
export const getLang = (): Promise<any> => {
  return apiGet(API.getLang)
}
export const setLang = (data: string): Promise<any> => {
  return apiPost(API.setLang + data)
}
export const logOut = (): Promise<any> => {
  return apiGet(API.logOut)
}
export const platformList = (data: any): Promise<any> => {
  return apiPost(API.platformList, data, ContentType.APPLICATION_JSON)
}
export const getpermissions = (data): Promise<string[]> => {
  return apiGet(API.permissions, data)
}
